from flask import jsonify


class HttpCode():
    ok = 200
    paramerror = 400
    autherror = 401
    servererror = 500


def resful_result(code, message, data):
    return jsonify({'code': code, 'message': message, 'data': data})


def success(message='', data=None):
    return resful_result(HttpCode.ok, message, data)


def param_error(message='', data=None):
    return resful_result(HttpCode.paramerror, message, data)


def auth_error(message='', data=None):
    return resful_result(HttpCode.autherror, message, data)


def server_error(message='', data=None):
    return resful_result(HttpCode.servererror, message, data)
